Fixed point, binary-coded decimal (BCD) data format is a widely used format in commercial applications, such as in business, finance, and administrative systems for companies and governments. For instance, financial applications handling financial data often employ this format, such as many banking applications and homegrown banking codes. The common programming language used by these applications or codes is often COBOL or PL/1. This particular data format is also the default data type for certain databases, such as DB2™, offered by International Business Machines Corporation of Armonk, N.Y., and an SAP server, offered by SAP SE of Walldorf, Germany.
When performing certain types of arithmetic operations on binary-coded decimal data, it is necessary to know whether the result of the operation is within a target data width for the result. For instance, this is a widely used feature in COBOL codes, where inputs and results may have different widths, and the application expects COBOL to check for validity of the operation. One approach to checking for validity is to generate the result, and then apply a mask to the result to identify potential overflow digits, and check whether any of the digits is non-zero in the overflow.